package com.util;



import com.exception.CustomerException;

import javax.servlet.http.HttpServletResponse;

/**
 * Created by zxd on 2021/12/11 14:30
 */
public class ResponseUtils {


    /**
     * 发送json数据给客户端
     * @param json
     * @param response
     */
    public static  void responseToJson(String json, HttpServletResponse response){
        try {
            response.setContentType("application/json;charset=UTF-8");
            response.getWriter().write(json);
        }catch (Exception e){
            e.printStackTrace();
            throw new CustomerException("发送json失败!");
        }
    }

}
